package com.swdegao.api.callback;

import com.alibaba.fastjson2.JSONObject;
import com.swdegao.api.util.RocketMQUtils;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.io.IOException;

@Slf4j
@RestController
@RequestMapping("/Api/DongJianNBBigCallBack")
public class DongJianNBBigCallBackApi {
    @Autowired
    private RocketMQUtils rocketMQUtils;

    private static String topic = "dongjiannbbigTopic";
    private static String tag = "dongjiannbbigtag01";
    @PostMapping("/callback")
    public  void callback(@RequestBody String reslut) throws IOException {
        JSONObject jo = JSONObject.parseObject(reslut);
        String imei = jo.getString("IMEI");
        log.info(reslut);
        rocketMQUtils.sendMessage(imei, topic, tag, reslut);
    }
}
